﻿<phone:PhoneApplicationPage
    x:Class="CameraBanking.Camera"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:CameraBanking.Resources"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Landscape"
    Orientation="Landscape"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="False">

    <phone:PhoneApplicationPage.Resources>
        <local:LocalizedStrings x:Key="LocalizedStrings"/>
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot"
          Width="800"
          Height="800"
          Margin="0,-200">
        <Grid.Background>
            <VideoBrush x:Name="viewfinderBrush" Stretch="UniformToFill">
                <VideoBrush.RelativeTransform>
                    <CompositeTransform x:Name="viewfinderTransform"
                                        CenterX="0.5"
                                        CenterY="0.5"/>
                </VideoBrush.RelativeTransform>
            </VideoBrush>
        </Grid.Background>

        <Grid.Resources>
            <!--Transform from QrCode To Barcode Layout-->
            <Storyboard x:Name="FromQrCodeToBarcodeLayout">
                <!--Layout FrameworkElement Transformation-->
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot"
                                               Storyboard.TargetProperty="(FrameworkElement.Margin)">
                    <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                            <Thickness>0,-200</Thickness>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>

                <!--TextNotification FrameworkElement Transformation-->
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextNotification"
                                               Storyboard.TargetProperty="(FrameworkElement.Margin)">
                    <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                            <Thickness>12,200,75,0</Thickness>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>

                <!--Guide FrameworkElement Transformation-->
                <DoubleAnimation Storyboard.TargetName="Guide"
                                 Storyboard.TargetProperty="Width"
                                 From="360" To="640" Duration="0:0:0.125" AutoReverse="False"/>
                <DoubleAnimation Storyboard.TargetName="Guide"
                                 Storyboard.TargetProperty="Height"
                                 From="360" To="150" Duration="0:0:0.125" AutoReverse="False"/>
                <DoubleAnimation Storyboard.TargetName="GrayImage"
                                 Storyboard.TargetProperty="Width"
                                 From="160" To="120" Duration="0:0:0.125" AutoReverse="False"/>
                <DoubleAnimation Storyboard.TargetName="viewfinderBrush"
                                 Storyboard.TargetProperty="VideoBrush.RelativeTransform.Rotation"
                                 From="90" To="0" Duration="0:0:0.5" AutoReverse="False"/>

                <!--GrayImageStackPanel FrameworkElement Transformation-->
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GrayImageStackPanel"
                                               Storyboard.TargetProperty="(FrameworkElement.Margin)">
                    <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                            <Thickness>0,0,0,160</Thickness>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>

                <!--GrayImageStackPanel FrameworkElement Transformation-->
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GrayImage"
                                               Storyboard.TargetProperty="(FrameworkElement.Margin)">
                    <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                            <Thickness>6,0,0,6</Thickness>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>

                <!--Guide FrameworkElement Transformation-->
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ImageNotification"
                                               Storyboard.TargetProperty="Visibility">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>

            <!--Transform from Barcode to QrCode Layout-->
            <Storyboard x:Name="FromBarcodeToQrCodeLayout">
                <!--Layout FrameworkElement Transformation-->
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot"
                                               Storyboard.TargetProperty="(FrameworkElement.Margin)">
                    <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                            <Thickness>-200</Thickness>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>

                <!--TextNotification FrameworkElement Transformation-->
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextNotification"
                                               Storyboard.TargetProperty="(FrameworkElement.Margin)">
                    <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                            <Thickness>170,100,170,0</Thickness>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>

                <!--Guide FrameworkElement Transformation-->
                <DoubleAnimation Storyboard.TargetName="Guide"
                                 Storyboard.TargetProperty="Width"
                                 From="640" To="360" Duration="0:0:0.125" AutoReverse="False"/>
                <DoubleAnimation Storyboard.TargetName="Guide"
                                 Storyboard.TargetProperty="Height"
                                 From="150" To="360" Duration="0:0:0.125" AutoReverse="False"/>
                <DoubleAnimation Storyboard.TargetName="GrayImage"
                                 Storyboard.TargetProperty="Width"
                                 From="120" To="160" Duration="0:0:0.125" AutoReverse="False"/>
                <DoubleAnimation Storyboard.TargetName="viewfinderBrush"
                                 Storyboard.TargetProperty="VideoBrush.RelativeTransform.Rotation"
                                 From="0" To="90" Duration="0:0:0.5" AutoReverse="False"/>

                <!--GrayImageStackPanel FrameworkElement Transformation-->
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GrayImageStackPanel"
                                               Storyboard.TargetProperty="(FrameworkElement.Margin)">
                    <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                            <Thickness>160,600,160,75</Thickness>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>

                <!--GrayImageStackPanel FrameworkElement Transformation-->
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GrayImage"
                                               Storyboard.TargetProperty="(FrameworkElement.Margin)">
                    <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                            <Thickness>16,0,0,0</Thickness>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>

                <!--Guide FrameworkElement Transformation-->
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ImageNotification"
                                               Storyboard.TargetProperty="Visibility">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
        </Grid.Resources>

        <TextBlock Name="TextNotification"
                   Margin="12,200,75,0"
                   TextWrapping="Wrap"
                   VerticalAlignment="Top"
                   Foreground="Blue"
                   Text="{Binding Path=LocalizedResources.TextNotification, Source={StaticResource LocalizedStrings}}">
            <TextBlock.Resources>
                <Storyboard x:Name="TextNotificationFromVisibleToInvisible">
                    <DoubleAnimation Storyboard.TargetName="TextNotification"
                                     Storyboard.TargetProperty="Opacity"
                                     From="1"
                                     To="0"
                                     Duration="0:0:5"
                                     AutoReverse="False"/>
                </Storyboard>
            </TextBlock.Resources>
        </TextBlock>

        <Rectangle Name="Guide"
                   Height="150"
                   Width="640"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center"
                   Stroke="Blue"
                   StrokeDashArray="3"
                   StrokeThickness="4"
                   Opacity="1"
                   Visibility="Visible"/>

        <StackPanel Name="GrayImageStackPanel"
                    VerticalAlignment="Bottom"
                    Orientation="Horizontal"
                    Margin="0,0,0,160"
                    Width="800">
            <Image x:Name="GrayImage"
                   Width="160"
                   Height="120"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Bottom"
                   Margin="6,0,0,6"
                   Stretch="Uniform"/>
            <TextBlock Name="ImageNotification"
                       VerticalAlignment="Bottom"
                       HorizontalAlignment="Left"
                       Margin="16"
                       Width="540"
                       TextWrapping="Wrap"
                       Opacity="0"
                       Text="{Binding Path=LocalizedResources.ImageNotification, Source={StaticResource LocalizedStrings}}"
                       Foreground="Blue"
                       Visibility="Visible">
                <TextBlock.Resources>
                    <Storyboard x:Name="ImageNotificationFromVisibleToInvisible">
                        <DoubleAnimation Storyboard.TargetName="ImageNotification"
                                         Storyboard.TargetProperty="Opacity"
                                         From="1"
                                         To="0"
                                         Duration="0:0:10"
                                         AutoReverse="False"/>
                    </Storyboard>
                </TextBlock.Resources>
            </TextBlock>
        </StackPanel>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="False"
                              IsMenuEnabled="True"
                              Opacity="0.5">
            <!--<shell:ApplicationBarIconButton Text="qr code"
                                            IconUri="/Assets/appbar.qr.png"
                                            Click="QrCodeOrBarCode_Click"/>-->
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>